<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<title>青年旅行家</title>
		<link rel="stylesheet" type="text/css" href="../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../css/base.css" />
	</head>
	<body>
		<div class="login-wrap" id='header'>
			<a class="close" href="#" tapmode="" onclick="api.closeWin()"></a>
			<h2 class="login-h"><a class="login-forget" href="#" tapmode="" onclick="openForgot();api.closeWin();">忘记密码？</a>
			<a class="login-reg" href="#"  tapmode="" onclick="openRegister1();api.closeWin();">注册</a></h2>
			<ul class="login-form">
				<li class="bt">
					<span>手机号</span>					 
					<input class="login-form-input" type="text" placeholder="请输入..." value="" name="" id="userName" />
				</li>
				<li>
					<span>密码</span>
					<input class="login-form-input"  type="password" placeholder="请输入..."  value="" name="" id="password" />
				</li>
			</ul>
			<a class="initial-reg-btn" href="#" tapmode="" onclick="finished()">登录</a>
			<p class="login-agree-p">
				点击登录即表示同意<a class="login-agree-con" href="#" >用户协议</a>
			</p>
		</div>
	</body>
	<script type="text/javascript" src="../script/api.js"></script>
	<script type="text/javascript" src="../script/app.js"></script>
	<script type="text/javascript" src="../script/zepto.min.js"></script>
	<script type="text/javascript" src="../script/yzxVerification.js"></script>
	<script type="text/javascript">
		function finished() {
			var userName = $('#userName').val();
			var pwd = md5($('#password').val());
			var url = "/rest/user/login";
			var data = {
				"phone" : userName,
				"password" : pwd
			};
			ajaxRequest(url, 'post', data, function(ret, err) {
				//bMsg=true;
				//msg(ret);
				if (ret && ret.body) {
					var userData = ret.body;
					$api.setStorage('uid', userData.userId);
					$api.setStorage('pwd', pwd);
					$api.setStorage('photo', userData.photoBasecode);
					userData.photoBasecode = "";
					log(userData);
					$api.setStorage('userData', userData);					
					api.sendEvent({
						name : 'loadFocus'
					});
					api.closeWin();
					api.execScript({
		                name: 'root',
		                script: "randomSwitchBtn(null,'bbtn01',0);"
		            });				
				}
				else
				{
					api.toast({
	                    msg:'用户或密码错误，请重新登陆！'
                    });					
				}
				//
			})
		}

		apiready = function() {
			var $header = $api.byId('header');
			$api.fixIos7Bar($header);
		}
	</script>
</html>